home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_081 / conman / conman.doc < prev    next >
Text File  |  1992-05-06  |  15KB  |  306 lines

  1. ==========================================================================
  2.                              ConMan V0.99B
  3.                   Copyright (c) 1987 by William S. Hawes
  4. ==========================================================================
  5.  
  6. ConMan is a replacement console handler that provides line editing and
  7. command line histories.  It runs under AmigaDOS (V1.1 or V1.2) and is
  8. completely transparent to any application program that uses CON: windows.
  9. Once installed, all windows opened by AmigaDOS will automatically use the
  10. ConMan handler.  This includes command windows opened by NEWCLI as well
  11. as any data input/output windows that your program uses.
  12.  
  13. In addition to the basic line-editing functions, ConMan provides a number
  14. of "standard" control-key options, several function-key definitions, and a
  15. procedural interface designed to assist "shell" programs and other utilities.
  16. It can also be opened as a (switchable) RAW: mode handler and as a 'pipe'.
  17.  
  18.  
  19. Line Editing.
  20. ConMan allows you to edit the active (command) line using the left- and
  21. right-arrow keys for cursor positioning.  The DEL key removes the character
  22. under the cursor, and the BACKSPACE key deletes the character to the left
  23. of the cursor.  The shifted left-arrow key skips to the beginning of the
  24. current or previous word, and the shifted right-arrow key skips to the
  25. position beyond the end of the current or next word.
  26.  
  27. The editing mode may be set to either insert or overstrike characters, and
  28. is toggled by the CTRL-A key.  This input mode is controlled by two global
  29. flags maintained in the ConHandler library structure.  One flag determines
  30. the mode in effect when the window is first opened and after each line is
  31. entered, and defaults to "insert."  The other flag determines whether the
  32. mode is "sticky" -- whether it remains set or reverts to the initial setting
  33. after each line is entered.  The mode flags may be selected when you first
  34. install ConMan, and can be changed at any time using the provided SetCMan
  35. command utility.  Try experimenting with the input modes to see which you
  36. prefer.  Note that these are global flags and therefore apply to ALL ConMan
  37. windows.
  38.  
  39. Several control keys are provided to delete all or part of the active line.
  40. CTRL-X deletes the entire line, while CTRL-Y deletes from the cursor position 
  41. to the end of the line.  CTRL-Z deletes both the current line and any lines 
  42. that have been entered (but not yet read); this is very handy if you want to
  43. completely abandon all typed-ahead lines.  CTRL-R provides a less drastic
  44. recourse by recalling entered lines one at a time and posting them back to 
  45. the command line.
  46.  
  47. CTRL-S and CTRL-Q have been implemented to hold and release the screen        
  48. output, respectively.  While the CTRL-S action is not strictly necessary,
  49. since entering any character will halt output to the screen, it is a standard
  50. control option.  CTRL-W clears the entire window and refreshes the command
  51. line.
  52.  
  53. One other control character is recognized:  CTRL-\ sends an end-of-file
  54. (a zero-length block) to the task reading from the handler.
  55.  
  56. All characters not explicitly required for editing purposes are passed on
  57. to the command line.  In order to provide a consistent display, characters
  58. that might cause interference with the display (e.g. CTRL-L) are displayed
  59. as a caret followed by an uppercase alphabetic.  Miscellaneous non-printable
  60. characters are displayed as a hash mark.
  61.  
  62.  
  63. Command History.
  64. Previously-entered lines may be recalled sequentially with the up-arrow key.
  65. If you go past the one you want, the down-arrow key will retrieve the next
  66. (more recent) line.  The shifted up-arrow key recalls the oldest line, and
  67. shifted down-arrow recalls the most recent line.  
  68.  
  69. The command history can be maintained in one of two modes.  In the default
  70. mode, recalled lines are not reentered into the history buffer unless the
  71. line was "touched", and the history index pointer is left set at the
  72. retrieved line.  This mode is convenient if you often go back deep into
  73. the buffer to retrieve sequences of commands.
  74.  
  75. In "true history" mode, every line is reentered into the history buffer,
  76. even if it was recalled and not modified.  The history pointer is always
  77. reset (to the most recent line) whenever a line is placed into the buffer.
  78.  
  79. The history mode may be selected when ConMan is installed or by using
  80. the SetCMan utility.
  81.  
  82. The history buffer is organized as a fixed-length memory "pool" with a
  83. default length of 488 bytes.  The number of lines that can be saved depends
  84. on the line lengths, but is generally in the range of 25-30.  The default
  85. size may be changed by modifying a field in the library structure, but let
  86. me know if this is too small (or too big; we don't want to waste memory.)
  87.  
  88.  
  89. Function Keys.
  90. Four function keys have been assigned default actions.  Key F1 shrinks
  91. ("iconifies") the window to its minimum size, while F2 "zooms" the window 
  92. to its maximum size (usually the entire screen.)  Both keys act as "toggles", 
  93. and shrunken windows may be zoomed (and vice-versa.)  If the window was
  94. opened without a sizing gadget, neither F1 or F2 will have any effect.
  95.  
  96. Key F9 "dips" the screen to 3/4 of the display height, and should be useful 
  97. if you're working with multiple screens and need to peek at the one in back.  
  98. F10 rearranges a window from front-to-back, and acts as a toggle provided 
  99. that you don't deactivate the window.
  100.  
  101.  
  102. Window Definition.
  103. ConMan accepts the standard AmigaDOS window specifications.  For example,
  104. "CON:160/50/320/100/MyWindow" specifies a window 320x100 pixels in size,
  105. beginning in position (160,50).  The numeric parameters are truncated
  106. against the maximum screen size, so a larger-than-normal window may be
  107. safely specified (for those of you using "morerows").  The default size
  108. is the full screen width and height.  ConMan computes the minimum size
  109. for the window based on the length of the title and the gadgets present.
  110. The actual size of the window is used as the upper bound for the minimum, 
  111. so very small windows (e.g. "con:0/0/1/1/") can be specified.
  112.  
  113. ConMan also accepts a specification in the form "CON:w20480", where the 
  114. hex digits following the "w" are the absolute address of an Intuition 
  115. window pointer.  If you're writing in 'C', the following sequence would 
  116. serve to open a window and attach a DOS console to it:
  117.  
  118.       window = OpenWindow(&newwindow);   /* get a window          */
  119.       sprintf(buffer,"CON:W%x",window);  /* build the name string */
  120.       file  = Open(buffer,MODE_OLDFILE); /* open a console stream */ 
  121.  
  122. Windows may be opened on a custom screen by including the screen pointer
  123. in the specification string, as in "CON:S123abc/10/10/300/100/MyWindow".
  124.  
  125. Various Intuition options and gadgets may be selected by including a list
  126. of attributes after the window title.  Here's how it works:  Put another 
  127. slash ('/') after the window title, and follow it with any of the attribute 
  128. options below:
  129.  
  130.    A ==> Activate          default: activated
  131.    B ==> BackDrop                   not a backdrop
  132.    C ==> Close gadget               no close gadget
  133.    D ==> Depth gadget               depth gadget
  134.    M ==> Move (drag) gadget         drag gadget
  135.    N ==> NoBorder                   border (sorry, 'B' was used)
  136.    R ==> Refresh (SMART/SIMPLE)     smart refresh
  137.    S ==> Sizing gadget              sizing gadget
  138.    Z ==> Zero-Zero                  not a GZZ
  139.  
  140. Each attribute serves to TOGGLE the corresponding windows flag, so including
  141. an attribute twice will cancel the effect.  A closing slash is optional.
  142. For those of you who wanted a slash in your titles:  sorry.
  143.  
  144. Example: CON:10/10/300/100/Behind/nb/  creates a borderless backdrop window.
  145.          CON:10/10/300/100/Fixed/acm   creates a nonactivated window, with
  146.                                        a close gadget, that won't budge.
  147.  
  148. Installation.
  149. ConMan requires that two files be copied to your SYS: disk (don't worry,
  150. they're both small.)  File "My-Handler" (184 bytes) must be placed in the 
  151. SYS:L directory, to keep all those bigger handlers company.  The file
  152. "conhandler.library" (5816 bytes) must be placed in the your LIBS:
  153. directory, which is normally SYS:LIBS.  If you received ConMan in the form
  154. of an ARCed file, be sure to rename "conlib.lib" and "myhandlr," or use
  155. the provided "install" script to copy the files.
  156.  
  157. Once these files are present, execute ConMan (988 bytes) to install the
  158. handler.  This command should only be run once, as it allocates 20 bytes
  159. of memory for the handler name string which won't be released (there is no 
  160. provision in DOS for removing a handler, anyway.)  Several command-line
  161. arguments may be specified when ConMan is executed:
  162.  
  163.    -c ==> install as CON: (default)
  164.    -o ==> select overstrike mode
  165.    -q ==> execute "quickly" (don't open a window)
  166.    -r ==> install as RAW:
  167.    -s ==> select "sticky" mode
  168.    -t ==> maintain "true history"
  169.  
  170. These command options may appear in any order and remain in effect until
  171. the computer is rebooted.  The -q option is recommended if the ConMan
  172. command is to be placed in your startup script (SYS:s/startup-sequence).
  173.  
  174. A separate utility program called SetCMan (136 bytes) has been provided to
  175. modify some of the global mode flags.  Use SetCMan to change the -o, -s,
  176. or -t options at any time.
  177. Examples: conman  -c -q -t
  178.           setcman -o -s -t
  179.  
  180. Distribution.
  181. This program is to be distributed as shareware to Amigoid life-forms 
  182. everywhere!  Make sure your friends get a copy.  Comments and contributions
  183. will be appreciated and may be sent to:
  184.  
  185.       William S. Hawes        (bix: whawes)
  186.       P.O. Box 308
  187.       Maynard, MA 01754
  188.       (617) 568-8695
  189.  
  190. Additional documentation and the assembler source code will be available
  191. in the near future.  
  192.  
  193. I will be other releasing other Amiga products, both through shareware and 
  194. normal commercial channels.  Watch for:
  195.    ARexx ... the REXX language for the Amiga (June, 1987)
  196.    Mini-Shell ... just enough DOS (August, 1987)  
  197.  
  198.  
  199. Further Notes.
  200. This is the last Beta version before the "final" (is anything ever final?)
  201. release of ConMan.  Some debugging code still remains here.  Function key 
  202. F5 toggles a flag that causes a DisplayBeep everytime a "WaitForChar" 
  203. packet is dispatched.  Most programs will not use the "WaitForChar" function,
  204. since a Read to the CON: device will block until characters are available
  205. anyway.  F6 toggles a flag that DisplayBeeps whenever a "break" signal is
  206. passed on (i.e. is applied to your hapless task).  Also, an extraneous
  207. message port (called 'MyCon') will appear in the Ports list.  These testing
  208. features will go away RSN.
  209.  
  210. The program was developed and tested under V1.2; at least one V1.1
  211. dependency was found and fixed (DoIO to the console device scratched D7).
  212. Let me know if other problems exist.  I spent a lot of time making it
  213. work using the DOS handler-loading mechanism so that it would be backwards
  214. compatible.
  215.  
  216. A passing note:  The interaction of the "shrink" and "zoom" keys proved
  217. to be a little trickier than it first appeared; I ended up spending the 
  218. better part of a day finding state transitions that seemed intuitive.  
  219. Anyone who doesn't like the current implementation is invited to submit a 
  220. state diagram with the desired transitions ...
  221.  
  222. One warning with regard to the "shrink" and "zoom":  rapid toggling between
  223. window states will crash the machine.  The problem appears to be an 
  224. interaction between Intuition and the console device, and I looking for a
  225. reasonable work-around before adopting an ugly kludge.  Until then, take
  226. it easy on the keys, OK?  
  227.  
  228. An additional warning: the console device exhibits serious problems with 
  229. supporting windows below some minimum size.  Opening windows of certain
  230. sizes (e.g. con:0/0/10/20/) may cause the machine to crash, whether or not
  231. ConMan is active.  For these reasons, it is highly recommended that you
  232. avoid console windows smaller than 60X25 or so.
  233.  
  234.  
  235. Function Key Interrupts.
  236. The ConHandler library provides routines to support a push-down stack of
  237. function-key contexts so that user programs can receive interrupts related
  238. to keyboard events.  Whenever a function key event (or more generally, 
  239. any raw event) occurs, the console handler first calls the user-supplied 
  240. function at the top of the context stack.  Your function is free to "eat" 
  241. the event, change it to something else, or take any other action.  Some  
  242. restrictions apply (after all, these are asynchronous events), but this 
  243. should allow for some interesting programming.  A separate program called
  244. "SideShow" has been included as an example of function-key processing.
  245. The full source code to "SideShow" is available for programmers interested
  246. in using the interrupt facilities.  Note to interested programmers:  let me 
  247. know if you'd like to try out the procedural interface and I'll post the
  248. necessary header files and binding routines.
  249.  
  250.  
  251. Using ConMan as a 'Pipe' Handler.
  252. ConMan can be mounted as a 'pipe' handler, a facility often used in "shell"
  253. programs for interprocess communications.  A 'pipe' is opened simultaneously
  254. for read and write, and the characters written into it are queued up to be
  255. read.  The maximum size for the pipe is specified when it is opened; once
  256. this limit is reached, any processes writing into it will be put to sleep
  257. until some characters have been read.  The default size for the ConMan
  258. 'pipe' device is 4000 bytes.
  259.  
  260. Mounting ConMan as a pipe handler requires the use of the mount command,
  261. and therefore works only under v1.2 of the operating system.  Place the
  262. included mountlist file in your DEVS: directory (or append it to the
  263. existing file), and then issue the command "mount pip:".
  264.  
  265. Opening a pipe is accomplished by a call to the DOS Open() function with
  266. a special argument code.  The initial open counts as TWO opens, assuming
  267. that the returned filehandle will be copied by the caller.  Since copying
  268. DOS structures is tricky, a function called DupFileHandle() is available
  269. in the ConHandler library.  A code fragment to open a 10,000 byte pipe
  270. device might look like this:
  271.  
  272.       ConHandlerBase = OpenLibrary("conhandler.library",0);
  273.  
  274.       fh1 = Open("pip:10000",999L);
  275.       fh2 = DupFileHandle(fh1);
  276.  
  277.       .
  278.       .
  279.       .
  280.       Close(fh1);                   /* close the first   */
  281.       Close(fh2);                   /* close the second  */
  282.  
  283. Note that if you want to use the higher-level 'C' library functions with
  284. the 'pipe' filehandles, you'll have to arrange to get the DOS filehandles
  285. into the appropriate I/O structures.
  286.  
  287. Normally one filehandle will be given to a "producer" (writer) process,
  288. and the other will go to a "consumer" (reader) process.  Each is free to
  289. close their half of the pipe at any time; the pipe handler closes only
  290. after BOTH filehandles have been closed.
  291.  
  292.  
  293. Bugs.
  294. The only known bug occurs when the handler is being used in RAW: mode
  295. with the ED editor.  The editor works fine until it exits, whereupon the
  296. window closes and ED (not me) GURUs with a "8700004" code.  The problem
  297. seems to be timing-related; if a second open is obtained on the RAW:
  298. window, ED exits without any problems.
  299.  
  300.  
  301. Acknowledgements.
  302. Special thanks to John Toebes and the Software Distillery for all the great 
  303. suggestions, and to everyone who called in with comments or contributions.
  304.  
  305.                                     WSH (06/02/87)
  306.